{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	{eq name="$diagnosis_id" value="0"}
	<h3 class="pb-3">新增</h3>
	{else/}
	
	{/eq}
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray">回复内容<font>*</font></td>
			<td>
				<input style="height:100px" type="text" name="content" lay-verify="required" lay-reqText="请输入回复内容" placeholder="请输入回复内容" class="layui-input"
			  {notempty name="$note.title" }value="{$note.title}" {/notempty}>
			</td>
			
		</tr>
		
		
		<input type="hidden" name="status" value="1">
		
	</table>
	<div class="py-3">
		<input type="hidden" name="diagnosis_id" value="{$diagnosis_id}" />
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
<div style="width:95%;margin: 0 auto;">
	{notempty name="$recover"}
	{volist name="$recover" id="v"}	
	<div style="width:100%;border:1px solid #EEEEEE;margin-top:10px">			
	<tr  class="" id="del{$v.id}">
    
    <td>
        <div class="" style="padding:20px">
            
                回复内容：{$v.content}
            
        </div>
    </td>
    <td data-field="cate_title" data-key="1-0-2" data-content="小麦" class="">
        <div align="left" style="padding:20px">
        	<span class="">
                回复人：{$v.expert}

            </span>
        
            <span class="" style="margin-left:30px">
                回复时间：{$v.create_time | date='Y-m-d H:i'}

            </span>
            <span class="" style="margin-left:30px;color:red" lay-event="del" onclick="del({$v.id})">
                删除此条回答

            </span>
        </div>
    </td>
    
</tr>
</div>	
{/volist}
{/notempty}
</div>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool','tinymce'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,laydate = layui.laydate;
		//日期范围
		laydate.render({
			elem: '#date',
			range: ['#start_time', '#end_time'],
			rangeLinked:true
		});

		//编辑器初始化
		var editor = layui.tinymce;
		var edit = editor.render({
			selector: "#container",
			images_upload_url: '/api/index/upload/sourse/tinymce',//图片上传接口
			height: 500
		});
		
		//监听提交
		form.on('submit(webform)', function (data) {
			/*data.field.content = tinyMCE.editors['container'].getContent();
			if (data.field.content == '') {
				layer.msg('请先完善公告内容');
				return false;
			}*/
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			tool.post("/note/expert/recover_add/diagnosis_id/{$diagnosis_id}", data.field, callback);
			return false;
		});

		//监听行工具事件
		form.on('del', function(obj) {
			console.log(obj);
			/*var data = obj.data;
			if (obj.event === 'edit') {
				tool.side("/note/expert/add?id="+data.id);
				return;
			}
			if (obj.event === 'recover') {
				tool.side("/note/expert/recover_add?diagnosis_id="+data.id);
				return;
			}
			if (obj.event === 'del') {
				layer.confirm('确定删除该问诊吗？', {
					icon: 3,
					title: '提示'
				}, function(index) {
					let callback = function (e) {
						layer.msg(e.msg);
						if (e.code == 0) {
							obj.del();
						}
					}
					tool.delete("/note/expert/delete", {id: data.id}, callback);
					layer.close(index);
				});
			}*/
		});
}
function del(id){
	layer.confirm('确定删除该回复吗？', {
		icon: 3,
		title: '提示'
	}, function(index) {
		$.ajax({
			url: "/note/expert/delete_recover/type/recover/id/"+id,
			type:'get',
			success:function(res){
				layer.msg('删除成功');
				location.reload();					
				//仅节点左侧图标控制收缩
				
			}
		})	
		layer.close(index);
	});
	//return false;
	
}
</script>
{/block}
<!-- /脚本 -->